<template>
  <div>
    <a-card :bordered="false">
      <div style="display: flex; flex-wrap: wrap">
        <head-info title="我的待办" :content="this.newlist.length" :bordered="true" />
      </div>
    </a-card>
    <a-card style="margin-top: 24px" :bordered="false" title="标准列表">
      <!-- <div slot="extra">
        <a-radio-group>
          <a-radio-button>全部</a-radio-button>
          <a-radio-button>进行中</a-radio-button>
          <a-radio-button>等待中</a-radio-button>
        </a-radio-group>
        <a-input-search style="margin-left: 16px; width: 272px;" />
      </div> -->
      <!-- <a-button type="dashed" style="width: 100%" icon="plus">添加</a-button> -->
      <a-list
        size="large"
        :pagination="{
          showSizeChanger: true,
          showQuickJumper: true,
          pageSize: 5,
          total: 50,
        }"
      >
        <a-list-item
          v-for="items in newlist"
          :key="items.dispatch_id"
          
        >
          <a-list-item-meta :description="items.car_number">
            <!-- <a-avatar slot="avatar" size="large" shape="square" src="https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png"/> -->
            <a slot="title">{{ items.dispatch_id }}</a>
          </a-list-item-meta>
          <div slot="actions">
            <a-menu-item><a @click="agree(items.dispatch_id)">同意</a></a-menu-item>
            <a-menu-item><a @click="refuse(items.dispatch_id)">拒绝</a></a-menu-item>
          </div>
          <div class="list-content">
            <div class="list-content-item">
              {{ index }}
              <span>员工姓名</span>
              <p>{{ items.employee_name }}</p>
            </div>
            <div class="list-content-item">
              <span>员工电话</span>
              <p>{{ items.employee_phone }}</p>
            </div>
            <div class="list-content-item">
              <span>目标地址</span>
              <p>{{ items.position }}</p>
            </div>
            <div class="list-content-item">
              <span>派车原因</span>
              <p>{{ items.des }}</p>
            </div>
          </div>
        </a-list-item>
      </a-list>
    </a-card>
  </div>
</template>

<script>
import HeadInfo from "../../components/tool/HeadInfo";
import { request, METHOD } from "@/utils/request";
export default {
  name: "StandardList",
  components: { HeadInfo },
  data() {
    return {
      api_str: "http://localhost:8088/order/dispatch_order_state_list",
      agree_or_disagree: "http://localhost:8088/order/agree_or_disagree02",
      new_id:'',
      loading: false,
      rev_data: "收到的响应",
      newlist: [],
  
    };
  },
  methods: {
    agree (dispatch_id) {
      // console.log(dispatch_id);
      this.new_id=dispatch_id;
      console.log(this.new_id);
      request(this.agree_or_disagree, METHOD.POST,{ state: 1, id: this.new_id }).then(() => {
        
    }).catch((err)=>{
      console.log(err);
    });
    },
    refuse (dispatch_id) {
      // console.log(dispatch_id);
      this.new_id=dispatch_id;
      console.log(this.new_id);
      request(this.agree_or_disagree, METHOD.POST,{ state: 0, id: this.new_id }).then((res) => {
      console.log(res);
    });
    },
    
  },
  created() {
    request(this.api_str, METHOD.GET).then((res) => {
      // console.log(res);
      this.loading = false;
      this.newlist = res.data.data;
      // console.log(this.newlist);
      // console.log(this.newlist.dispatch_id);
    });
  },
};
</script>

<style lang="less" scoped>
.list-content-item {
  color: @text-color-second;
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
  span {
    line-height: 20px;
  }
  p {
    margin: 4px 0 0;
    line-height: 22px;
  }
}
</style>
